/* js code for feature product customization */


/* select box entry changed */
$(document).delegate('.kor-valuelist-selection', 'change', function(){
	changeSelection (this);
	return false;
})

// clear selectbox after editing the element input fields
$(document).delegate('.kor-product-customization div.kor-cust-elements input', 'change', function(){
	$('.kor-valuelist-selection').each(function() { 
		this.value='';
	});
})

// update the input fields after the selectbox value has changed
function changeSelection (selection)
{
	var selectioncombi = [];  // element names
	var dimensionnames = [];  // value list dimension names

	if (selection.value != '') {
		selectioncombi = eval(selection.value); 
	}
	
	dimensionnames = eval(selection.getAttribute('data-cust-dimensionnames'));
	
	for(i=0;i<dimensionnames.length;i++){
		$('.'+dimensionnames[i]).each(function() { 
			if (selection.value != '') $(this).attr ('value',selectioncombi[i]);
			else $(this).attr ('value','');
		});
	}
}
